package com.chocho.javacompileserver.controller;

import com.chocho.javacompileserver.service.StudentService;
import com.chocho.javacompileserver.vo.Code;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by chocho on 2022/3/12.
 */
@RestController
public class CompileController {
    @Autowired
    private StudentService studentService;

    private Logger logger = LoggerFactory.getLogger(CompileController.class);

    @PostMapping("/java/compile")
    @ResponseBody
    public Map<String, Object> compile(@RequestBody Code code){
        logger.info(code.getArgs());
        logger.info(code.getSource());
        Map<String, Object> map = studentService.compileJava(code);
        return map;
    }
}
